package com.aaa.stact;

import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class StackUtil {
    private static final String TAG = "StackUtil";


    public static Throwable filter() {
        List<StackTraceElement> stackTraceList = new ArrayList();

        Throwable throwable = new Throwable();
        StackTraceElement[] stackTrace = throwable.getStackTrace();
        for (int i = 1; i < stackTrace.length; i++) {
            StackTraceElement stackTraceElement = stackTrace[i];
            if (stackTraceElement.getClassName().contains("net.sourceforge.opencamera")) {
                stackTraceList.add(stackTraceElement);
            }
        }

        StackTraceElement[] stackTraceDes = new StackTraceElement[stackTraceList.size()];
        StackTraceElement[] stackTraceElements = stackTraceList.toArray(stackTraceDes);
        Log.d(TAG, "get: stackTraceDes=" + stackTraceDes + " stackTraceElements=" + stackTraceElements);

        throwable.setStackTrace(stackTraceDes);
        return throwable;
    }
}
